'''
Created on Sep 23, 2011

@author: root
'''
import wx
import LoginDlg

class MyMenu(wx.MenuBar):
    
    def __init__(self, frame):
        wx.MenuBar.__init__(self)
        self.frame = frame
        
        fileMenu = wx.Menu()
        login = fileMenu.Append(wx.ID_ANY, '&Login')
        self.frame.Bind(wx.EVT_MENU, self.OnLogin, login)
        
        fileMenu.Append(wx.ID_OPEN, '&Open')
        fileMenu.Append(wx.ID_SAVE, '&Save')
        fileMenu.AppendSeparator()

        imp = wx.Menu()
        imp.Append(wx.ID_ANY, 'Import newsfeed list...')
        imp.Append(wx.ID_ANY, 'Import bookmarks...')
        imp.Append(wx.ID_ANY, 'Import mail...')

        fileMenu.AppendMenu(wx.ID_ANY, 'I&mport', imp)

        qmi = wx.MenuItem(fileMenu, wx.ID_EXIT, '&Quit\tCtrl+W')
        fileMenu.AppendItem(qmi)
        self.frame.Bind(wx.EVT_MENU, self.OnQuit, qmi)
        
        viewMenu = wx.Menu()        
        self.shst = viewMenu.Append(wx.ID_ANY, 'Show statubar', 
            'Show Statusbar', kind=wx.ITEM_CHECK)
        self.shtl = viewMenu.Append(wx.ID_ANY, 'Show toolbar', 
            'Show Toolbar', kind=wx.ITEM_CHECK)
        self.frame.Bind(wx.EVT_MENU, self.ToggleStatusBar, self.shst)
        self.frame.Bind(wx.EVT_MENU, self.ToggleToolBar, self.shtl)
        viewMenu.Check(self.shst.GetId(), True)
        viewMenu.Check(self.shtl.GetId(), True)
        
        self.Append(fileMenu, '&File')
        self.Append(viewMenu, '&View')
        
        
        # toolbar and statusbar
        self.frame.toolbar = self.frame.CreateToolBar()
        self.frame.toolbar.AddLabelTool(1, '', wx.Bitmap('../imgs/help.ico'))
        self.frame.toolbar.Realize()

        self.frame.statusbar = self.frame.CreateStatusBar()
        self.frame.statusbar.SetStatusText('Ready')
        
    def OnLogin(self, e):
        self.frame.loginDlg = LoginDlg.LoginDlg(self.frame)
        self.frame.loginDlg.ShowModal()
        
    def OnQuit(self, e):
        self.frame.Close()
        
    def ToggleStatusBar(self, e):
        
        if self.shst.IsChecked():
            self.frame.statusbar.Show()
        else:
            self.frame.statusbar.Hide()

    def ToggleToolBar(self, e):
        
        if self.shtl.IsChecked():
            self.frame.toolbar.Show()
        else:
            self.frame.toolbar.Hide()   
    
    pass
